import request from '@/utils/request'

const API_NAME = '/bms/books'

export default {
  // 获取所有图书
  queryAll() {
    return request({
      url: `${API_NAME}/`,
      method: 'get'
    })
  },
  // 分页获取所有图书
  queryByPage(page, limit, searchObj) {
    return request({
      url: `${API_NAME}/${page}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },
  // 分页获取可借图书
  queryBorrowByPage(page, limit, searchObj) {
    return request({
      url: `${API_NAME}/borrow/${page}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },
  // 修改一个图书
  update(book) {
    return request({
      url: `${API_NAME}/`,
      method: 'put',
      data: book
    })
  },
  // 新增一个图书
  insert(book) {
    return request({
      url: `${API_NAME}/`,
      method: 'post',
      data: book
    })
  },
  // 根据ID删除一个图书
  deleteById(id) {
    return request({
      url: `${API_NAME}/${id}`,
      method: 'delete'
    })
  },
  // 根据ID获取一个图书
  queryById(id) {
    return request({
      url: `${API_NAME}/${id}`,
      method: 'get'
    })
  }

}
